<template>
  <view>
    <u-navbar :title="NavTitle" :immersive="true" :is-back="false" :background="background"
              :border-bottom="false"></u-navbar>

    <view class="me-top-wrap">
      <!--			<image class="top-bg" :src="BestImgUrl+'/me/me-top-bg.png'"></image>-->
      <view class="top-bg">

      </view>
      <view class="my_info_wrap">
        <view class="top-info-box">
          <view class="my-info u-flex">
            <image class="my-tx" v-if="!userInfo.id" :src="BestImgUrl+'/home_logo.png'"></image>
            <image class="my-tx" v-else :src="userInfo.avatar" @click="Tomyinfo()"></image>
            <view class="my-name" v-if="!userInfo.id" @click="Tologin()">
              <view>登录/注册</view>
            </view>
            <view class="my-name" v-else>
              <view>{{ userInfo.nickname || '暂无昵称' }}</view>
              <view class="u-flex" @click="copy_no(userInfo.id)">ID: {{ userInfo.id }}
                <image :src="imgurlBwc+'/order/copy@2x.png'"
                       style="margin-left: 10rpx; width: 32rpx;height: 32rpx;"></image>
              </view>
            </view>
            <view class="right-icon" v-if="userInfo.id" @click="Tomyinfo()">
              <u-icon name="arrow-right" color="#999999" size="28"></u-icon>
            </view>
          </view>

        </view>
        <view class="gongju_lan">
          <view class="gongju_title">
            <image class="gongju_title_bg" :src="BestImgUrl+'/me/Mask group.png'"></image>
            <view class="gongju_title_dj u-flex">
              <image mode="widthFix" :src="imgurlBwc+'/user/zs@3x.png'" style="width: 100rpx;height: 84rpx;"></image>
              <view style="color: #FEF0D7;font-size: 28rpx">
                <text style="width: 1000rpx">
                  已认证账号数&nbsp;{{ userInfo.identification || "0" }}
                </text>
              </view>
            </view>

            <!--						<image mode="widthFix" class="gongju_title_dj" :src="BestImgUrl+'/me/Group 34838.png'" v-if="userInfo.vip_level == 0"></image>-->
            <!--						<image mode="widthFix" class="gongju_title_dj" :src="BestImgUrl+'/me/Group 34839.png'" v-if="userInfo.vip_level == 1"></image>-->
            <!--						<image mode="widthFix" class="gongju_title_dj" :src="BestImgUrl+'/me/Group 34836.png'" v-if="userInfo.vip_level == 2"></image>-->
            <!--						<image mode="widthFix" class="gongju_title_dj" :src="BestImgUrl+'/me/Group 34837.png'" v-if="userInfo.vip_level == 3"></image>-->

            <view class="sjrz" @click="Torenzheng()">升级认证</view>
          </view>
          <view class="u-flex"
                style="width: 690rpx;background-color: white;border-radius: 0 0 20rpx 20rpx;padding: 21rpx 0;;margin-left: 30rpx;justify-content: space-between">
            <view @click="ToYue()" class="u-flex" style="flex: 1;justify-content: center">
              <image mode="widthFix" :src="imgurlBwc+'/user/qbao@3x.png'" style="width: 52rpx;height: 52rpx;"></image>
              <view style="font-size: 28rpx;color: #333333;margin-left: 10rpx;">我的钱包</view>
              <u-icon name="arrow-right" color="#888888" size="21"></u-icon>
            </view>
            <view class="u-flex" style="flex: 1;justify-content: center">
              <image mode="widthFix" :src="imgurlBwc+'/user/kbao@3x.png'" style="width: 52rpx;height: 52rpx;"></image>
              <view style="font-size: 28rpx;color: #333333;margin-left: 10rpx;">红包卡券(0)</view>
              <u-icon name="arrow-right" color="#888888" size="21"></u-icon>
            </view>
          </view>
          <!--我的收益-->
          <view style="background-color: white;margin: 20rpx 30rpx;border-radius: 20rpx;padding: 30rpx;">
            <view class="u-flex" @click="ToYue()">
              <view style="font-size: 32rpx;color: #3D3D3D;font-weight: bold;flex: 1">我的收益</view>
              <view class="u-flex" style="margin-left: 10rpx;color: #999999;font-size: 26rpx">
                明细
                <u-icon name="arrow-right" color="#999999" size="24"></u-icon>
              </view>
            </view>
            <view style="margin-top: 20rpx"></view>
            <u-line></u-line>
            <view class="u-flex" style="border-radius: 0 0 20rpx 20rpx;padding: 21rpx 0;justify-content: space-between">
              <view style="width: 340rpx;justify-content: center" @click="ToYue()">
                <view style="font-size: 26rpx;color: #3D3D3D;display: flex;">
                  <text>可提现余额(元)</text>
                  <image mode="heightFix" :src="imgurlBwc+'/user/withdrawal_platform.png'"
                       style="height: 32rpx;margin-right: 10rpx"></image>
                </view>
                <view class="u-flex" style="font-size: 26rpx;margin-top: 13rpx">
                  <view style="color: #FF7800;font-size: 36rpx;flex: 1;font-weight: bold;">{{
                      userInfo.money || '0.00'
                    }}
                  </view>
                  <view style="border-radius: 200rpx 200rpx 200rpx 200rpx;
                  border: 2rpx solid #FFB36F;color: #FFB36F;line-height: 44rpx;
                  font-weight: bold;font-size: 24rpx;width: 100rpx;height: 44rpx;text-align: center">提现
                  </view>
                </view>
              </view>
              <view style="width: 1px;height: 58rpx;background-color: #ececec;margin: 0 38rpx"></view>
              <view style="flex: 1;justify-content: center" @click="ToYue()">
                <view style="font-size: 26rpx;color: #888888;">累计节省(元）</view>
                <view class="u-flex" style="font-size: 26rpx;margin-top: 13rpx">
                  <view style="color: #666666;font-size: 36rpx;flex: 1;font-weight: bold;">{{ userInfo.all_money || '0.00' }}</view>
                </view>
              </view>
            </view>
            <u-line></u-line>
            <view class="u-flex" style="margin-top: 26rpx" @click="ToYue()">
              <view style="width: 178rpx">
                <view style="color: #888888;font-size: 24rpx" class="u-flex">试吃官收益
                  <u-icon name="arrow-right" color="#888888" size="21"></u-icon>
                </view>
                <view style="color: #3D3D3D;font-weight: bold;font-size: 32rpx;margin-top: 16rpx">{{ userInfo.mt_refund_amount }}</view>
              </view>
              <view style="width: 160rpx">
                <view style="color: #888888;font-size: 24rpx" class="u-flex">累计团员
                  <u-icon name="arrow-right" color="#888888" size="21"></u-icon>
                </view>
                <view style="color: #3D3D3D;font-weight: bold;font-size: 32rpx;margin-top: 16rpx">{{ userInfo.member_count }}</view>
              </view>
              <view style="width: 160rpx">
                <view style="color: #888888;font-size: 24rpx" class="u-flex">探店收益
                  <u-icon name="arrow-right" color="#888888" size="21"></u-icon>
                </view>
                <view style="color: #3D3D3D;font-weight: bold;font-size: 32rpx;margin-top: 16rpx">{{ userInfo.order_refund_amount }}</view>
              </view>
              <view style="flex: 1">
                <view style="color: #888888;font-size: 24rpx" class="u-flex">有效团员
                  <u-icon name="arrow-right" color="#888888" size="21"></u-icon>
                </view>
                <view style="color: #3D3D3D;font-weight: bold;font-size: 32rpx;margin-top: 16rpx">{{ userInfo.active_member_count }}</view>
              </view>
            </view>
          </view>

          <!--          <view class="my_tongji u-flex">
                      <view class="my_tongji_item" @click="ToYue()">
                        <view>¥{{ userInfo.money || '0.00' }}</view>
                        <view>我的余额
                          <u-icon name="arrow-right" color="#999999" size="24"></u-icon>
                        </view>
                      </view>
                      <view class="my_tongji_item" @click="Toshouyi()">
                        <view>¥{{ userInfo.income_money || '0.00' }}</view>
                        <view>邀请收益
                          <u-icon name="arrow-right" color="#999999" size="24"></u-icon>
                        </view>
                      </view>
                      <view class="my_tongji_item">
                        <view>{{ userInfo.create_order_num || '0.00' }}</view>
                        <view>探店数量
                          <u-icon name="arrow-right" color="#999999" size="24"></u-icon>
                        </view>
                      </view>
                    </view>-->
          <!--挑战赛-->
          <view class="challenge_box">
            <view class="u-flex" style="justify-content: space-between;margin-bottom: 20rpx;">
              <view style="text-align: center;flex: 1" v-for="(item,index) in nav1" :key="index" @click="topage(index)">
                <view>
                  <image :src="nav1[index].image" style="height: 64rpx;width: 64rpx"></image>
                </view>
                <view style="font-size: 26rpx;color: #666666;line-height: 36rpx;margin-top: 10rpx">
                  {{ nav1[index].name }}
                </view>
              </view>
            </view>
            <view  v-if="isChallengeOpen && isToken" class="challenge_progress">
              <swiper class="challenge_swiper" :autoplay="false" interval="5000" @change="challengeChange" style="height: 250rpx;">
                <swiper-item v-for="(item, index) in challengeList" :key="index" style="width: 100%">
                  <view class="label_text">
                    {{ currentMenuIndex + 1 }}/{{ challengeList.length }}
                  </view>
                  <view class="challenge_swiper_item">
                    <view class="challenge_item_img">
                      <view class="challenge_item_img_text">
                        <text style="font-size: 52rpx">{{ item.reward_value ? item.reward_value.split('.')[0] : 0 }}</text>
                        <text style="font-size: 26rpx">元</text>
                      </view>
                      <image :src="imgurlBwc + '/money/money_weixin_icon.png'" mode="widthFix" style="width: 100%;height: 100%;"></image>
                    </view>
                    <view class="challenge_item_content">
                      <view class="challenge_item_content_title">
                        <view class="challenge_item_content_title_text ellipsis-one-line">{{ item.title }}</view>
                        <view class="challenge_count_down">
                          <text>活动倒计时：</text>
                          <u-count-down
                              :timestamp="countdowndays(item)"
                              :show-days="true"
                              :show-hours="false"
                              :show-minutes="false"
                              :show-seconds="false"
                              :show-border="true"
                              font-size="26"
                              color="#FF402F"
                              bgColor="#F8F8F8"
                              border-color="#ffffff"
                              separator="zh"
                              separator-size="20"
                              separator-color="#FF4E0D">
                          </u-count-down>
                          <u-count-down
                              :timestamp="countdowntime(item)"
                              :show-days="false"
                              :show-hours="true"
                              :show-minutes="true"
                              :show-seconds="true"
                              :show-border="true"
                              font-size="26"
                              color="#FF402F"
                              bgColor="#F8F8F8"
                              border-color="#ffffff"
                              separator="colon"
                              separator-size="20"
                              separator-color="#FF4E0D">
                          </u-count-down>
                        </view>
                        <view class="challenge_item_content_title_msg ellipsis-two-line">{{ item.description }}</view>
                        <view class="challenge_timeLine">
                          <view class="challenge_timeLine_item">
                            <view class="challenge_timeLine_item_line">
                              <u-line :color="item.current_progress > 0 ? '#FF7F14' : '#DEDEDE'"></u-line>
                              <u-line :color="item.current_progress > 0 ? '#FF7F14' : '#DEDEDE'"></u-line>
                            </view>
                            <view class="challenge_timeLine_round" :class="item.current_progress > 0 ? 'challenge_item_active_bg' : ''" style="left: 25%;"></view>
                            <view class="challenge_timeLine_text" :class="item.current_progress > 0 ? 'challenge_item_active_text' : ''" style="left: calc(25% - 16rpx);">第1{{ item.challenge_type == 1 ? '人' : '天' }}</view>
                          </view>
                          <view v-if="item.target_value > 2" class="challenge_timeLine_item">
                            <view class="challenge_timeLine_item_line">
                              <u-line :color="item.current_progress > 1 ? '#FF7F14' : '#DEDEDE'"></u-line>
                              <u-line :color="item.current_progress > 1 ? '#FF7F14' : '#DEDEDE'"></u-line>
                            </view>
                            <view class="challenge_timeLine_round" :class="item.current_progress > 1 ? 'challenge_item_active_bg' : ''" style="left: 50%;"></view>
                            <view class="challenge_timeLine_text" :class="item.current_progress > 1 ? 'challenge_item_active_text' : ''" style="left: calc(50% - 16rpx)">
                              第{{ item.current_progress > 1 ? item.current_progress : 2 }}{{ item.challenge_type == 1 ? '人' : '天' }}
                            </view>
                          </view>
                          <view class="challenge_timeLine_item">
                            <view class="challenge_timeLine_item_line">
                              <u-line color="#DEDEDE"></u-line>
                              <u-line color="#DEDEDE"></u-line>
                            </view>
                            <view class="challenge_timeLine_round" :class="item.current_progress == item.target_value ? 'challenge_item_active_bg' : ''" style="right: 25%;"></view>
                            <view class="challenge_timeLine_text" :class="item.current_progress == item.target_value ? 'challenge_item_active_text' : ''" style="right: calc(25% - 30rpx)">
                              第{{ item.target_value }}{{ item.challenge_type == 1 ? '人' : '天' }}
                            </view>
                          </view>
                        </view>
                      </view>
                    </view>
                  </view>
                </swiper-item>
              </swiper>
            </view>
          </view>
          <!--我的订单-->
          <view style="margin: 20rpx 30rpx;background-color: white;border-radius: 20rpx;padding: 30rpx">
            <view class="u-flex" @click="Toorder(0)">
              <view style="font-size: 32rpx;color: #3D3D3D;font-weight: bold;flex: 1">我的订单</view>
              <view class="u-flex" style="margin-left: 10rpx;color: #999999;font-size: 26rpx">
                全部订单
                <u-icon name="arrow-right" color="#999999" size="24"></u-icon>
              </view>
            </view>
            <view style="height: 28rpx"></view>
            <u-line></u-line>
            <view style="height: 28rpx"></view>
            <view class="u-flex" style="justify-content: space-between;">
              <view v-for="(item,index) in nav2" :key="index">
                <view style="text-align: center;flex: 1;position: relative" @click="Toorder(item.type)">
                  <!--                  <span v-if="index===0 && DaiFukuan.length != 0" style="width: 36rpx;height: 36rpx;-->
                  <!--                background-color: #f00;border-radius: 200rpx;color: #ffffff;font-size: 22rpx; display: flex;-->
                  <!--                align-items: center;justify-content: center;position: absolute;top: -8rpx;left: 58rpx;">{{ DaiFukuan.length }}</span>-->
                  <view>
                    <image :src="item.image" style="height: 64rpx;width: 64rpx"></image>
                  </view>
                  <view style="font-size: 26rpx;color: #666666;line-height: 36rpx;margin-top: 10rpx">{{ item.name }}
                  </view>
                </view>
              </view>
            </view>
          </view>
          <!--平台加盟-->
          <view @click="ToJoin" class="franchise">
            <view class="franchise_btn">
              <image :src="imgurlBwc + '/user/user_btn01.png'" mode="widthFix" style="width: 100%"></image>
            </view>
            <image :src="imgurlBwc + '/user/user_banner01.png'" mode="widthFix" style="width: 100%"></image>
          </view>
                    <!--<view class="order_gjl">
                      <view class="order_gjl_box">
                        <view class="order_gjl_title u-flex">
                          <view>订单中心</view>
                          <view @click="Toorder(0)">全部
                            <u-icon name="arrow-right" color="#999999" size="24"></u-icon>
                          </view>
                        </view>
                        <view class="gongju_menu u-flex">
                          <view class="gongju_menu_item" @click="Toorder(0)">
                            <image :src="BestImgUrl+'/me/Group 34854.png'"></image>
                            <view>我的订单</view>
                          </view>
                          <view class="gongju_menu_item" @click="Toorder(1)">
                            <span v-if="DaiFukuan.length != 0">{{ DaiFukuan.length }}</span>
                            <image :src="BestImgUrl+'/me/Group 34851.png'"></image>
                            <view>待付款</view>
                          </view>
                          <view class="gongju_menu_item" @click="Toorder(2)">
                            <span v-if="DaiShiyong.length != 0">{{ DaiShiyong.length }}</span>
                            <image :src="BestImgUrl+'/me/Group 34850.png'"></image>
                            <view>待使用</view>
                          </view>
                          <view class="gongju_menu_item" @click="Toorder(3)">
                            <span v-if="DaiShangchuan.length != 0">{{ DaiShangchuan.length }}</span>
                            <image :src="BestImgUrl+'/me/Group 34852.png'"></image>
                            <view>待上传</view>
                          </view>
                          <view class="gongju_menu_item" @click="Toorder(4)">
                            <span v-if="DaiShenhe.length != 0">{{ DaiShenhe.length }}</span>
                            <image :src="BestImgUrl+'/me/Group 34853.png'"></image>
                            <view>待审核</view>
                          </view>
                        </view>
                      </view>
                    </view>-->
        </view>
      </view>
    </view>

    <view class="center_wrap">
      <!--<view class="swpier_box" v-if="cpsSlunbolist.length != 0">
        <view class="ad_box">
          <view class="shopTuijian">
            <swiper class="swiper-box" :indicator-dots="true" indicator-color='#fff'
                    indicator-active-color='#ff9900' :autoplay="true" interval="3000" :circular='true'
                    previous-margin="0" next-margin="0">
              <swiper-item v-for="(item,index) in cpsSlunbolist" :key="index">
                <view class="scrollx_items">
                  <view class="ren_info">
                    <view class="hbaotu" @click="clickslide(item,index)">
                      &lt;!&ndash; #ifdef H5 &ndash;&gt;
                      <block v-if="item.type === 4">
                        <wx-open-launch-weapp id="launch-btn" :username="item.original_id"
                                              :path="item.path"
                                              style="position: absolute;z-index: 4;left: 0;width: 100%;height:100%;opacity: 0.3;">
                          <script type="text/wxtag-template">
                            <style></style>
                            <div
                                style="position: absolute;top: 0; left: 0; width: 100%;height: 100% ; opacity: 0;"></div>
                          </script>
                        </wx-open-launch-weapp>
                      </block>
                      &lt;!&ndash; #endif &ndash;&gt;
                      <image :src="item.image" mode=""></image>
                    </view>
                  </view>
                </view>
              </swiper-item>
            </swiper>
          </view>
        </view>
      </view>-->
      <view class="wodefuwu" v-for="(item,index) in meNavBar" :key="index">
        <view class="fuwu_title">{{ item.name }}</view>
        <view class="wodefuwu_item" style="display: flex;justify-content: space-between;">
          <!--<u-row gutter="5">
            <u-col span="2" v-for="(items,indexs) in item.menu" :key="indexs"
                   @click="Tomenus(items,indexs)">
              <view class="fuwu_2_item">
                <image :src="items.image"></image>
                <view>{{ items.name }}</view>
              </view>
            </u-col>
          </u-row>-->
          <view @click="Tomenus(items,indexs)" v-for="(items,indexs) in item.menu" :key="indexs" class="fuwu_2_item" style="width: 25%;">
            <image :src="items.image"></image>
            <view>{{ items.name }}</view>
          </view>
          <!-- <view class="fuwu_2_item">
            <image :src="BestImgUrl+'/me/m-2.png'"></image>
            <view>福利活动</view>
          </view>
          <view class="fuwu_2_item">
            <image :src="BestImgUrl+'/me/m-3.png'"></image>
            <view>福利活动</view>
          </view>
          <view class="fuwu_2_item">
            <image :src="BestImgUrl+'/me/m-4.png'"></image>
            <view>福利活动</view>
          </view> -->
        </view>
      </view>
    </view>
    <!--底部tabber-->
    <view class="tabbar_height" :style="{height: tabberHeight + 'px'}"></view>
    <view class="tabber">
      <tdTabbar :tabbarIndex="tabbarIndex" @updateTabbar="updateTabbar" />
    </view>
    <view style="height: 30rpx;"></view>
  </view>
</template>

<script>
import tdTabbar from "@/components/td-tabbar/td-tabbar.vue";
const app = getApp();
export default {
  components: {
    tdTabbar,
  },
  data() {
    return {
      BestImgUrl: app.globalData.imgurl,
      imgurlBwc: app.globalData.imgurlBwc,
      tabbarIndex: 5, // 底部tabbar索引
      tabberHeight: 0, // 底部tabber高度
      background: {
        backgroundColor: 'transparent',
      },
      NavTitle: '',
      userInfo: {},
      meNavBar: [],
      cpsSlunbolist: [],

      DaiFukuan: [],
      DaiShiyong: [],
      DaiShangchuan: [],
      DaiShenhe: [],
      nav1: [
        {image: app.globalData.imgurlBwc + '/user/领食挑战赛@3x.png', name: '领食挑战赛'},
        {image: app.globalData.imgurlBwc + '/user/天天领红包@3x.png', name: '福利中心 '},
        {image: app.globalData.imgurlBwc + '/user/我的探店@3x.png', name: '我的探店'},
        {image: app.globalData.imgurlBwc + '/user/福利中心@3x.png', name: '天天领红包'},
      ],
      nav2: [
        {image: app.globalData.imgurlBwc + '/user/代付款@3x.png', name: '待付款', type: 1, },
        {image: app.globalData.imgurlBwc + '/user/待使用@3x.png', name: '待使用', type: 10, },
        {image: app.globalData.imgurlBwc + '/user/待上传@3x.png', name: '待上传', type: 10, },
        {image: app.globalData.imgurlBwc + '/user/待审核@3x.png', name: '待审核', type: 10, },
        {image: app.globalData.imgurlBwc + '/user/待返款@3x.png', name: '待返款', type: 10, },
      ],
      // 挑战赛数据
      challengeList: [],
      // 当前选中的菜单索引
      currentMenuIndex: 0,
      isChallengeOpen: false, // 所属地区是否开启挑战赛
      // 是否登录
      isToken: false,
    }
  },
  onLoad() {
    let that = this
    let token = uni.getStorageSync('token')
    if (!token) {
      that.userInfo = {}
    } else {

    }
    // tabbar的高度
    uni.createSelectorQuery().select('.tabber').boundingClientRect(rect => {
      console.log('tabbar高度==', rect.height)
      that.tabberHeight = rect.height
    }).exec();
    that.GetMeNavBar()
    that.Cpslunbotu()
  },
  onShow() {
    let that = this
    let token = uni.getStorageSync('token')
    if (!token) {
      that.userInfo = {}
    } else {
      that.GetUserInfo()
      that.JiSuanOrderStatus()
      that.getUserChallengeList()
      //#ifdef MP-WEIXIN
      //绑定推荐人
      let pdi = {
        parent_id: uni.getStorageSync('parent_id'),
        reseller_id: {
          reseller_id: uni.getStorageSync('reseller_id') || ''
        }
      }
      that.isToken = true
      app.globalData.bindSaveParentId(pdi);
      //#endif

    }
  },
  onPageScroll(e) {
    if (e.scrollTop >= 1) {
      this.background.backgroundColor = '#ffffff'
      this.NavTitle = '个人中心'
    } else {
      this.background.backgroundColor = 'transparent'
      this.NavTitle = ''
    }
  },
  methods: {
    // 底部tabbar 点击事件
    updateTabbar(e){
      this.tabbarIndex = e
    },
    //计算出我的订单各个状态的数量
    JiSuanOrderStatus() {
      let that = this
      that.$api.GetTanDianOrder({
        page: 1,
        limit: 10,
        status: this.typs
      }).then(res => {
        console.log('订单状态', res.data.result);

        //待付款的
        let DaiFuKuan = []
        let DaiShiyong = []
        let DaiShangchuan = []
        let DaiShenhe = []
        res.data.result.forEach(function (item, index) {
          if (item.status == 1) {
            DaiFuKuan.push(item)
            //return false
          } else if (item.status == 2) {
            DaiShiyong.push(item)
            //return false
          } else if (item.status == 3) {
            DaiShangchuan.push(item)
            //return false
          } else if (item.status == 4) {
            DaiShenhe.push(item)
            //return false
          }
        });
        that.DaiFukuan = DaiFuKuan
        that.DaiShiyong = DaiShiyong
        that.DaiShangchuan = DaiShangchuan
        that.DaiShenhe = DaiShenhe

      }).catch(err => {

      });
    },
    isNoLogin() {
      let token = uni.getStorageSync('token')
      if (!token) {
        uni.showModal({
          title: '提示',
          content: '您还未登陆,是否去登录？',
          confirmColor: '#FF4910',
          confirmText: '去登录',
          success: function (res) {
            if (res.confirm) {
              uni.navigateTo({
                url: '/pages/login/login'
              })
            }
          }
        });
        return true
      } else {
        return false
      }
    },
    Torenzheng() {
      if(this.isNoLogin()){
        return
      }
      uni.navigateTo({
        url: '/sub_account/pages/account_list'
      })
      // TODO 升级认证
      // uni.navigateTo({
      // 	url: '/subpackageA/pages/Certification/Certification'
      // })
    },
    Cpslunbotu() {
      let that = this
      that.$api.MiaofanBanner({}).then(res => {
        that.cpsSlunbolist = res.data.result
      }).catch(err => {

      })
    },
    ToYue() {
      if(this.isNoLogin()){
        return
      }
      uni.navigateTo({
        url: '/mePages/pages/incomeInfo'
      })
    },
    Toshouyi() {

    },
    copy_no(id) {
      console.log("copy_no", id)
      uni.setClipboardData({
        data: id + "", // e是你要保存的内容
        success: function () {
          uni.showToast({
            title: '复制成功',
            icon: 'none'
          })
        },fail: function (e) {
          console.log("copy_noe", e)
          uni.showToast({
            title: '复制失败',     //提示的内容
            icon: 'none'
          })
        }
      });
    },
    Tomyinfo() {
      if(this.isNoLogin()){
        return
      }
      uni.navigateTo({
        url: '/subpackageA/pages/infoEdit'
      })
    },
    GetUserInfo() {
      let that = this
      that.$api.GetuserInfo({}).then(res => {
        console.log('个人信息', res.data.result);
        that.userInfo = res.data.result;
        uni.setStorageSync('userinfo', res.data.result)
      }).catch(err => {
        // uni.showToast({
        // 	title: err.data.msg,
        // 	icon: 'none',
        // 	duration: 4000
        // });
      });
    },
    GetMeNavBar() {
      let that = this
      that.$api.GetMeMenulist({}).then(res => {
        console.log('导航', res.data.result);
        this.meNavBar = res.data.result
      }).catch(err => {
        uni.showToast({
          title: err.data.msg,
          icon: 'none',
          duration: 4000
        });
      })
    },
    Toorder(type) {
      console.log('res==', type)
      if(this.isNoLogin()){
        return
      }
      // let url = '/subpackageA/pages/orders/orders?types=' + type
      let url = '/subpackageA/pages/orders/orders_gf?types=' + type
      uni.navigateTo({
        url: url
      })
    },
    Tologin() {
      uni.navigateTo({
        url: '/pages/login/login'
      })
    },
    //菜单跳转
    Tomenus(item, idx) {
      // if(this.isNoLogin() && idx != 0 && idx != 1 && idx != 2){
      //   return
      // }
      let that = this
      console.log(item)
      let token = uni.getStorageSync('token')
      if (!token) {
        // #ifdef H5 || MP-WEIXIN
        uni.navigateTo({
          url: '/pages/login/login'
        })
        // #endif

        // #ifdef APP-PLUS
        uni.navigateTo({
          url: '/subpackageB/pages/newAppLogin/newAppLogin'
        })
        // #endif

      } else {

        //跳转在线客服
        if (item.name == "在线客服" && item.id == 64) {

          // #ifdef MP-WEIXIN
          this.toCustomerServicePages()
          // #endif

          // #ifdef H5 || APP-PLUS
          this.callservice()
          // #endif

        } else if (item.type == 2) { //跳转tabbar类型
          uni.switchTab({
            url: item.path
          })
        } else if (item.type == 1) { //跳转nav类型
          uni.navigateTo({
            url: item.path
          })
        } else if (item.type == 3) { //跳转h5url类型

          // #ifdef MP-WEIXIN || APP-PLUS
          uni.navigateTo({
            url: '/pages/Webview/Webview?url=' + encodeURIComponent(JSON.stringify(item.path))
          })
          // #endif

          // #ifdef H5
          window.location.href = item.path
          // #endif
        } else if (item.type == 4) { //跳转小程序类型

          //#ifdef APP-PLUS
          plus.share.getServices(function (res) {
            var sweixin = null;
            for (var i = 0; i < res.length; i++) {
              var t = res[i];
              if (t.id == 'weixin') {
                sweixin = t;
              }
            }
            if (sweixin) {
              sweixin.launchMiniProgram({
                id: item.original_id,
                path: item.path,
                type: 0 // 微信小程序版本类型可取值： 0-正式版； 1-测试版； 2-体验版。 默认值为0
              });
            }
          }, function (res) {
          });
          //#endif

          //#ifdef MP-WEIXIN
          if (item.name == "粉丝福利群") {
            uni.navigateTo({
              url: item.path
            })
          } else {
            var appid = item.appid;
            var path = item.path;
            uni.navigateToMiniProgram({
              appId: appid,
              path: path,
              envVersion: 'release',
              success(res) {
              }
            });
          }
          //#endif

        }
      }
    },
    //点击轮播图
    clickslide(item, idx) {
      let that = this

      if (item.type == 2) { //跳转tabbar类型
        uni.switchTab({
          url: item.path
        })
      } else if (item.type == 1) { //跳转nav类型
        uni.navigateTo({
          url: item.path + '?title=' + item.title,
          animationType: 'pop-in'
        })
      } else if (item.type == 3) { //跳转h5url类型

        // #ifdef MP-WEIXIN || APP-PLUS
        uni.navigateTo({
          url: '/pages/Webview/Webview?url=' + encodeURIComponent(JSON.stringify(item.path)),
          animationType: 'pop-in'
        })
        // #endif

        // #ifdef H5
        window.location.href = item.path
        // #endif
      } else if (item.type == 4) { //跳转小程序类型

        //#ifdef APP-PLUS
        that.JumpMiniAppApp(item.original_id, item.path)
        //#endif

        // #ifdef MP-WEIXIN
        that.JumpMiniAppMini(item.appid, item.path)
        // #endif

      }
    },
    //跳转小程序-微信端
    JumpMiniAppMini(aid, apath) {
      uni.navigateToMiniProgram({
        appId: aid,
        path: apath,
        envVersion: 'release',
        success(res) {
        }
      });
    },
    //跳转小程序-APP
    JumpMiniAppApp(aid, apath) {
      plus.share.getServices(function (res) {
        var sweixin = null;
        for (var i = 0; i < res.length; i++) {
          var t = res[i];
          if (t.id == 'weixin') {
            sweixin = t;
          }
        }
        if (sweixin) {
          sweixin.launchMiniProgram({
            id: aid,
            path: apath,
            type: 0 // 微信小程序版本类型可取值： 0-正式版； 1-测试版； 2-体验版。 默认值为0
          });
        }
      }, function (res) {
      });
    },
  //   跳转到团长
    topage(i){
      console.log(i)
      if(i == 0){
        /* uni.switchTab({
          url: '/pages/QuanZi/make_money'
        }) */
        uni.navigateTo({
          url: '/subpackageB/pages/moneyChallengeList/moneyChallengeList'
        })
      } else if(i == 1){
        uni.switchTab({
          url: '/pages/QuanZi/make_money'
        })
      } else if(i == 2){
        uni.switchTab({
          url: '/pages/index/index'
        })
      }else{
        const data = {
          appid: "wxde8ac0a21135c07d",
          original_id: "gh_870576f3c6f9",
          path:"/index/pages/h5/h5?weburl=https%3A%2F%2Fclick.meituan.com%2Ft%3Ft%3D1%26c%3D2%26p%3D2HZ0ib5z6gf0",
          type: 2,
        }
        uni.openEmbeddedMiniProgram({
          appId: data.appid,
          path: data.path,
        })
      }
    },
    // 获取我的挑战任务列表
    getUserChallengeList() {
      let that = this
      that.$api.getUserChallengeActivityListAPI({
        status: that.status,
      }).then(res => {
        if (res.data.code == 200){
          res.data.result.list.forEach(item => {
            if (item.status == 1){
              that.challengeList.push(item)
            }
          })
          console.log('我的挑战任务列表', that.challengeList)
          // that.challengeList = res.data.result.list
        }
        if (that.challengeList.length > 0){
          that.isChallengeOpen = true
        }
      }).catch(err => {
        uni.showToast({
          title: err.data.msg,
          icon: 'none',
          duration: 2000
        });
      })
    },
    //倒计时计算
    countdowndays(item) {
      const now = new Date().getTime();
      let endTime = new Date(item.end_date).getTime()
      let isend = endTime - now > 0 ? (endTime - now) : 0;
      let seconds = this.$moment(isend).unix();
      // console.log('结束时间', seconds)
      return seconds
    },
    countdowntime(item) {
      const now = new Date().getTime();
      let endTime = new Date(item.end_date).getTime()
      let oneDay = 24 * 60 * 60 * 1000;
      let isend = endTime - now > 0 ? (endTime - now) : 0;
      let days = Math.floor(isend / oneDay);
      let times = isend - (days * oneDay)
      let seconds = this.$moment(times).unix();
      // console.log('结束时间', times)
      return seconds
    },
    /* swiper的change事件 */
    challengeChange(e){
      let that = this
      that.currentMenuIndex = e.detail.current;
    },
    /* 商家入驻 */
    ToJoin(){
      uni.navigateTo({
        url: '/subpackageA/pages/businessApply/businessApply'
      })
    },
  }
}
</script>

<style lang="scss">
page {
  background-color: #f2f2f2;
}

.center_wrap {
  padding: 0 24rpx;

  .swpier_box {
    .ad_box {
      margin-bottom: 20rpx;

      image {
        width: 100%;
        height: 148rpx;
      }
    }

    .shopTuijian {
      .swiper-box {
        height: 148rpx !important;
      }

      .scrollx_items {
        width: 100%;
        height: 148rpx;
        position: relative;

        .ren_info {
          position: relative;

          .hbaotu {
            position: relative;

            image {
              width: 100%;
              height: 148rpx;
              border-radius: 20rpx;
            }
          }
        }
      }
    }
  }

  .wodefuwu {
    padding: 24rpx;
    background-color: #ffffff;
    border-radius: 24rpx;
    margin: 0 0 30rpx 0;

    .fuwu_title {
      font-size: 32rpx;
      color: $zzy-text-color-333333;
      font-weight: bold;
      margin: 0 0 0 0;
    }

    .wodefuwu_item {
      text-align: center;

      .fuwu_2_item {
        text-align: center;
        margin-top: 30rpx;

        image {
          width: 56rpx;
          height: 56rpx;
          margin-bottom: 10rpx;
        }

        view {
          font-size: 24rpx;
          color: $zzy-text-color-333333;
        }
      }
    }
  }

  .menus_2 {
    padding: 24rpx;
    background-color: #ffffff;
    border-radius: 24rpx;
    margin: 0 0 30rpx 0;

    .menus_2_item {
      flex: 1;
      text-align: center;

      image {
        width: 86rpx;
        height: 86rpx;
        border-radius: 200rpx;
        background-color: #FEC8B2;
        margin-bottom: 10rpx;
      }

      view {
        font-size: 24rpx;
        color: $zzy-text-color-333333;
      }
    }
  }
}

.me-top-wrap {
  position: relative;
  overflow: hidden;

  .top-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 700rpx;
    background: linear-gradient(178deg, #FFF5B8 0%, #fdfae4 30%, #f2f2f2 80%, rgba(255, 255, 255, 0) 100%);
  }

  .my_info_wrap {
    position: relative;
    z-index: 2;

    .top-info-box {
      position: relative;
      padding: 84px 28rpx 24rpx 28rpx;

      .my-info {
        align-items: center;

        .my-tx {
          border-radius: 200rpx;
          width: 128rpx;
          height: 128rpx;
          border: 2px solid #ffffff;
        }

        .my-name {
          padding-left: 20rpx;

          view:nth-child(1) {
            font-size: 32rpx;
            color: $zzy-text-color-333333;
            font-weight: bold;
          }

          view:nth-child(2) {
            margin-top: 20rpx;
            color: $zzy-text-color-999999;
            font-size: 28rpx;
          }
        }

        .right-icon {
          margin-left: auto;
          border-radius: 200rpx;
          background-color: #FEFBF9;
          width: 64rpx;
          height: 64rpx;
          display: flex;
          align-items: center;
          justify-content: center;
        }
      }

      .my_tongji {
        margin: 46rpx 0 0 0;
        align-items: center;
        justify-content: space-between;

        .my_tongji_item {
          flex: 1;
          text-align: center;

          view:nth-child(1) {
            color: $zzy-text-color-333333;
            font-size: 40rpx;
            font-weight: bold;
          }

          view:nth-child(2) {
            color: $zzy-text-color-666666;
            font-size: 26rpx;
          }
        }
      }
    }

    .gongju_lan {
      margin-top: 20rpx;

      .order_gjl {
        background-color: #F4F4F4;
        border-radius: 30rpx 30rpx 0 0;
        padding: 26rpx;

        .order_gjl_box {
          background-color: #ffffff;
          padding: 24rpx;
          border-radius: 24rpx;

          .order_gjl_title {
            align-items: center;
            justify-content: space-between;

            view:nth-child(1) {
              font-size: 32rpx;
              color: $zzy-text-color-333333;
              font-weight: bold;
            }

            view:nth-child(2) {
              color: $zzy-text-color-999999;
              font-size: 24rpx;
            }
          }

          .gongju_menu {
            align-items: center;
            justify-content: space-between;
            margin-top: 30rpx;

            .gongju_menu_item {
              text-align: center;
              flex: 1;
              position: relative;

              span {
                display: inline-block;
                width: 40rpx;
                height: 40rpx;
                background-color: #f00;
                border-radius: 200rpx;
                color: #ffffff;
                font-size: 24rpx;
                display: flex;
                align-items: center;
                justify-content: center;
                position: absolute;
                top: -18rpx;
                right: 18rpx;
              }

              image {
                width: 55rpx;
                height: 55rpx;
                margin-bottom: 12rpx;
              }

              view {
                color: $zzy-text-color-333333;
                font-size: 24rpx;
              }
            }
          }
        }
      }

      .gongju_title {
        position: relative;
        width: 690rpx;
        margin: 0 30rpx;

        .sjrz {
          position: absolute;
          top: 50%;
          right: 6%;
          transform: translate(12%, -50%);
          color: #210000;
          font-size: 24rpx;
          border-radius: 200rpx;
          width: 160rpx;
          height: 56rpx;
          text-align: center;
          line-height: 56rpx;
          font-weight: bold;
          background: linear-gradient(93deg, #ECB694 0%, #FEE4CD 100%);
        }

        .gongju_title_bg {
          width: 100%;
          height: 140rpx;
        }

        .gongju_title_dj {
          width: 330rpx;
          height: 46rpx;
          position: absolute;
          top: 47rpx;
          left: 3%;
        }
      }
    }
  }
}
/* 挑战赛css */
.challenge_box{
  margin: 20rpx 30rpx;
  background-color: white;
  border-radius: 20rpx;
  padding: 30rpx;
  .challenge_progress{
    width: 100%;
    min-height: 250rpx;
    background: #F8F8F8;
    border-radius: 20rpx;
    .challenge_swiper{
      position: relative;
    }
    .label_text {
      background-color: #FFEED4;
      width: 76rpx;
      text-align: center;
      border-radius: 0 20rpx 0 20rpx;
      font-size: 28rpx;
      padding: 2rpx;
      position: absolute;
      top: 0;
      right: 0;
      color: #FF5429;
    }
    .challenge_swiper_item{
      padding: 20rpx;
      border-radius: 24rpx;
      display: flex;
      flex: 1;
      .challenge_item_img{
        width: 108rpx;
        height: 120rpx;
        position: relative;
        .challenge_item_img_text{
          width: 100%;
          height: 72rpx;
          line-height: 72rpx;
          position: absolute;
          top: 0;
          color: #FA642B;
          text-align: center;
        }
      }
      .challenge_item_content{
        flex: 1;
        display: flex;
        justify-content: space-between;
        align-items: center;
        .challenge_item_content_title{
          width: 100%;
          margin-left: 10rpx;
          .challenge_item_content_title_text{
            font-size: 28rpx;
            color: #222222;
            font-weight: bold;
            line-height: 40rpx;
            margin-bottom: 6rpx;
          }
          .challenge_count_down{
            font-size: 26rpx;
            display: flex;
            margin-bottom: 10rpx;
          }
          .challenge_item_content_title_msg{
            line-height: 40rpx;
            font-size: 26rpx;
            color: #888888;
            margin-bottom: 10rpx;
          }
          .challenge_timeLine{
            width: 100%;
            display: flex;
            justify-content: space-between;
            .challenge_timeLine_item{
              position: relative;
              flex: 1;
              .challenge_timeLine_item_line{
                display: flex;
              }
              .challenge_timeLine_round{
                width: 20rpx;
                height: 20rpx;
                background-color: #DEDEDE;
                border: 2rpx solid #FFFFFF;
                border-radius: 50%;
                position: absolute;
                top: -10rpx;
              }
              .challenge_timeLine_text{
                width: 60rpx;
                font-size: 20rpx;
                color: #666666;
                line-height: 40rpx;
                margin-top: 10rpx;
                position: absolute;
              }
            }
            .challenge_item_active_bg{
              background-color: #FF7F14 !important;
            }
            .challenge_item_active_text{
              color: #FF7F14 !important;
            }
          }
        }
        .challenge_item_content_btn{
          width: 140rpx;
          height: 56rpx;
          line-height: 56rpx;
          font-size: 28rpx;
          color: #FFFFFF;
          text-align: center;
          background: linear-gradient( 90deg, #FD3F03 0%, #FE7F08 100%);
          border-radius: 30rpx;
        }
        .during{
          width: 160rpx;
          height: 110rpx;
          line-height: 30rpx;
          color: #888888;
          background: #FFFFFF;
          border: 2rpx solid #888888;
          padding: 10rpx 0;
        }
      }
    }
  }
}
/* 平台加盟css */
.franchise{
  margin: 0 30rpx 20rpx;
  position: relative;
  .franchise_btn{
    width: 120rpx;
    height: 120rpx;
    position: absolute;
    top: 20rpx;
    right: 30rpx;
  }
}

</style>